home *** CD-ROM | disk | FTP | other *** search
/ Joystick Magazine 1996 May / cd joy 71No13.iso / pc / demos / eurosoc / source / hminetb.h < prev    next >
C/C++ Source or Header  |  1995-09-15  |  11KB  |  262 lines

  1. /****************************************************************************
  2. *
  3. *  File              : netbios.c
  4. *  Date Created      : 1/18/95
  5. *  Description       : NETBIOS support library header file
  6. *
  7. *  Programmer(s)     : Nick Skrepetos
  8. *  Last Modification : 9/11/95 - 2:41:22 PM
  9. *  Additional Notes  :
  10. *
  11. *****************************************************************************
  12. *          Copyright (c) 1994-95,  HMI, Inc.  All Rights Reserved           *
  13. ****************************************************************************/
  14.  
  15. #ifndef  _HMI_NETBIOS_DEFINED
  16. #define  _HMI_NETBIOS_DEFINED
  17.  
  18. // equates for interrupts used
  19. #define  _NETBIOS_INT         0x5c
  20.  
  21. // maximum nodes supported at once
  22. #define  _NETBIOS_MAX_NODES            _NETNOW_MAX_NODES
  23.  
  24. // broadcast command
  25. #define  _NETBIOS_BROADCAST            _NETBIOS_MAX_NODES + 1
  26.  
  27. // maximum number of packets that can be in packet queue
  28. #define  _NETBIOS_MAX_SEND_PACKETS     _NETNOW_MAX_SEND_PACKETS
  29. #define  _NETBIOS_MAX_LISTEN_PACKETS   _NETNOW_MAX_LISTEN_PACKETS
  30.  
  31. // size of the packet for transmission
  32. #define  _NETBIOS_DATA_PACKET          _NETNOW_DATA_PACKET
  33.  
  34. // offset of data 
  35. #define  _NETBIOS_DATA_OFFSET          sizeof( _NETBIOS_NCB )
  36.  
  37. // real mode memory sizes fro sending and receiving
  38. // datagrams.
  39. #define  _NETBIOS_REAL_SEND_SIZE       _NETBIOS_MAX_SEND_PACKETS * \
  40.                                        ( _NETBIOS_DATA_PACKET + _NETBIOS_DATA_OFFSET )
  41. #define  _NETBIOS_REAL_LISTEN_SIZE     _NETBIOS_MAX_LISTEN_PACKETS * \
  42.                                        ( _NETBIOS_DATA_PACKET + _NETBIOS_DATA_OFFSET )
  43.  
  44. // set structure packing to byte packing
  45. #pragma  pack(1)
  46.  
  47. // protected mode pointer
  48. typedef  struct
  49.                {
  50.  
  51.                   PSTR     pData;            // pointer to data
  52.  
  53.                } _PROT_PTR;
  54.  
  55. // real mode pointer
  56. typedef  struct
  57.                {
  58.  
  59.                   SHORT    wOffset;          // address offset
  60.                   SHORT    wSegment;         // address segment
  61.  
  62.                } _REAL_PTR;
  63.  
  64. // real/protected pointer
  65. typedef  union
  66.          {
  67.  
  68.             _PROT_PTR   sPointer;
  69.             _REAL_PTR   sRealPtr;
  70.  
  71.          } _PTR;
  72.  
  73. // network control block (NCB)
  74. typedef  struct   _tag_NETBIOS_NCB
  75.          {
  76.  
  77.             BYTE     bCommand;               // command
  78.             BYTE     bReturnCode;            // return code from command
  79.             BYTE     bLocalSession;          // local session number
  80.             BYTE     bNetworkNameNumber;     // network name number
  81.             _PTR     sPtr;                   // pointer to buffer
  82.             USHORT   wLength;                // length of buffer
  83.             BYTE     bCallName[ 16 ];        // destination computer
  84.             BYTE     bName[ 16 ];            // source computer
  85.             BYTE     bReceiveTimeOut;        // receive time out, 500 ms increments
  86.             BYTE     bSendTimeOut;           // send time out, 500 ms increments
  87.             PSTR     pPostFunction;          // pointer to post function
  88.             BYTE     bAdapter;               // adapter 0 or 1
  89.             BYTE     bCompletionCode;        // return code ( completion )
  90.             BYTE     bReserve[ 14 ];         // reserved for system
  91.  
  92.          } _NETBIOS_NCB;
  93.  
  94. // NetBIOS adapter status information
  95. typedef  struct   _tagNETBIOS_ADAPTER_STATUS
  96.          {
  97.  
  98.             BYTE     bCardID[ 6 ];                 // card id ( node addr )
  99.             BYTE     bReleaseLevel;                // release level
  100.             BYTE     bReserved1;                   // reserved
  101.             BYTE     bTypeOfAdapter;               // adapter type
  102.             BYTE     bOldOrNewParameters;          // parameters
  103.             USHORT   wReportingPeriodMinutes;      // reporting period
  104.             USHORT   wFrameRejectReceivedCount;    // rejected count
  105.             USHORT   wFrameRejectSentCount;        // rejected send count
  106.             USHORT   wReceivedDataFrameErrors;     // receive errors
  107.             USHORT   wUnsuccessfulTransmissions;   // unsuccessful transmissions
  108.             LONG     dwGoodTransmissions;          // good transmissions
  109.             LONG     dwGoodReceptions;             // good receptions
  110.             USHORT   wRetransmissions;             // retry transmissions
  111.             USHORT   wExhaustedResourceCount;      //
  112.             USHORT   wT1TimerExpiredCount;         //
  113.             USHORT   wTITimerExpiredCount;         //
  114.             BYTE     bReserved2[4];                // reserved
  115.             USHORT   wAvailableNCBS;               //
  116.             USHORT   wMaxNCBSConfigured;           //
  117.             USHORT   wMaxNCBSPossible;             //
  118.             USHORT   wBufferOrStationBusyCount;    //
  119.             USHORT   wMaxDatagramSize;             // max datagram size
  120.             USHORT   wPendingSessions;             //
  121.             USHORT   wMaxSessionsConfigured;       //
  122.             USHORT   wMaxSessionsPossible;         //
  123.             USHORT   wMaxFrameSize;                //
  124.             USHORT   wNameCount;                   //
  125.  
  126.             struct
  127.                   {
  128.  
  129.                      BYTE  bName[ 16 ];            // name
  130.                      BYTE  bNameNumber;            // name number in list
  131.                      BYTE  bNameStatus;            // status
  132.  
  133.                   } sNameTable[ 20 ];
  134.  
  135.          } _NETBIOS_ADAPTER_STATUS;
  136.  
  137.  
  138. // flags for send/listen element
  139. #define  _NETBIOS_ELEMENT_ACTIVE     0x8000        // element is active
  140. #define  _NETBIOS_ELEMENT_DATA       0x4000        // element has data waiting
  141. #define  _NETBIOS_ELEMENT_LISTENING  0x2000        // element is listening for packet
  142. #define  _NETBIOS_ELEMENT_SENDING    0x1000        // element is sending packet
  143.  
  144. // structure for send/listen elements
  145. typedef  struct   _tagNETBIOS_ELEMENT
  146.          {
  147.  
  148.             USHORT         wFlags;                 // misc flags
  149.             USHORT         wOffset;                // offset into data area
  150.             _NETBIOS_NCB   sNCB;                   // control block
  151.             _NETBIOS_NCB * pNCB;                   // pointer to NCB
  152.             PSTR           pHeader;                // application specific header
  153.             USHORT         wHSize;                 // application header size
  154.  
  155.          } _NETBIOS_ELEMENT;
  156.  
  157. // address structure for NetBIOS
  158. typedef  struct   _tagNETBIOS_LOCAL_TARGET
  159.          {
  160.  
  161.             BYTE  bNode[ 16 ];                      // node address
  162.  
  163.          } _NETBIOS_LOCAL_TARGET;
  164.  
  165. // equates for node addition
  166. enum
  167.    {
  168.       _NETBIOS_ADD_COMPLETE,
  169.       _NETBIOS_ADD_DUPLICATE,
  170.       _NETBIOS_ADD_LIST_FULL
  171.    };
  172.  
  173. // equates for node deletion
  174. enum
  175.    {
  176.       _NETBIOS_DELETE_COMPLETE,
  177.       _NETBIOS_DELETE_INVALID,
  178.    };
  179.  
  180. // equates for init error
  181. enum
  182.    {
  183.       _NETBIOS_INIT_NO_ERROR,
  184.       _NETBIOS_INIT_NO_MEMORY,
  185.       _NETBIOS_INIT_NO_NETBIOS,
  186.       _NETBIOS_INIT_NO_TEMPNAME
  187.    };
  188.  
  189. // reset structure packing
  190. #pragma  pack()
  191.  
  192. // NetBIOS commands
  193. #define  _NETBIOS_RESET                         0x32
  194. #define  _NETBIOS_CANCEL                        0x35
  195. #define  _NETBIOS_STATUS                        0xb3
  196. #define  _NETBIOS_STATUS_WAIT                   0x33
  197. #define  _NETBIOS_UNLINK                        0x70
  198. #define  _NETBIOS_ADD_NAME                      0xb0
  199. #define  _NETBIOS_ADD_NAME_WAIT                 0x30
  200. #define  _NETBIOS_ADD_GROUP_NAME                0xb6
  201. #define  _NETBIOS_ADD_GROUP_NAME_WAIT           0x36
  202. #define  _NETBIOS_DELETE_NAME                   0xb1
  203. #define  _NETBIOS_DELETE_NAME_WAIT              0x31
  204. #define  _NETBIOS_CALL                          0x90
  205. #define  _NETBIOS_CALL_WAIT                     0x10
  206. #define  _NETBIOS_LISTEN                        0x91
  207. #define  _NETBIOS_LISTEN_WAIT                   0x11
  208. #define  _NETBIOS_HANG_UP                       0x92
  209. #define  _NETBIOS_HANG_UP_WAIT                  0x12
  210. #define  _NETBIOS_SEND                          0x94
  211. #define  _NETBIOS_SEND_WAIT                     0x14
  212. #define  _NETBIOS_SEND_NO_ACK                   0xf1
  213. #define  _NETBIOS_SEND_NO_ACK_WAIT              0x71
  214. #define  _NETBIOS_CHAIN_SEND                    0x97
  215. #define  _NETBIOS_CHAIN_SEND_WAIT               0x17
  216. #define  _NETBIOS_CHAIN_SEND_NO_ACK             0xf2
  217. #define  _NETBIOS_CHAIN_SEND_NO_ACK_W           0x72
  218. #define  _NETBIOS_RECEIVE                       0x95
  219. #define  _NETBIOS_RECEIVE_WAIT                  0x15
  220. #define  _NETBIOS_RECEIVE_ANY                   0x96
  221. #define  _NETBIOS_RECEIVE_ANY_WAIT              0x16
  222. #define  _NETBIOS_SESSION_STATUS                0xb4
  223. #define  _NETBIOS_SESSION_STATUS_WAIT           0x34
  224. #define  _NETBIOS_SEND_DATAGRAM                 0xa0
  225. #define  _NETBIOS_SEND_DATAGRAM_WAIT            0x20
  226. #define  _NETBIOS_SEND_BROADCAST_DATAGRAM       0xa2
  227. #define  _NETBIOS_SEND_BROADCAST_DATAGRAM_W     0x22
  228. #define  _NETBIOS_RECEIVE_DATAGRAM              0xa1
  229. #define  _NETBIOS_RECEIVE_DATAGRAM_WAIT         0x21
  230. #define  _NETBIOS_RECEIVE_BROADCAST_DATAGRAM    0xa3
  231. #define  _NETBIOS_RECEIVE_BROADCAST_DATAGRAM_W  0x23
  232.  
  233. #endif
  234.  
  235. // function prototypes
  236. BOOL    cdecl    hmiNETBIOSInitSystem             ( W32 wNodes );
  237. BOOL  cdecl hmiNETBIOSUnInitSystem           ( VOID );
  238. W32    cdecl hmiNETBIOSGetActiveNodes         ( VOID );
  239. BOOL    cdecl hmiNETBIOSPostListen             ( VOID );
  240. BOOL    cdecl hmiNETBIOSInstalled              ( VOID );
  241. BOOL    cdecl    hmiNETBIOSAddName                ( PSTR szName );
  242. BOOL    cdecl    hmiNETBIOSDeleteName             ( PSTR szName );
  243. BOOL    cdecl    hmiNETBIOSGetAdapterStatus       ( VOID );
  244. VOID    cdecl hmiNETBIOSSortNodes              ( VOID );
  245. W32    cdecl hmiNETBIOSGetConsoleNode         ( VOID );
  246. VOID    cdecl hmiNETBIOSListenForPacket        ( _NETBIOS_NCB *  sNCB,
  247.                                                _NETBIOS_NCB ** pPacket );
  248. VOID    cdecl hmiNETBIOSSendPacket             ( _NETBIOS_NCB *  sNCB,
  249.                                                _NETBIOS_NCB ** pPacket, 
  250.                                                PSTR  pHeader, 
  251.                                                W32  wSize  );
  252. BOOL    cdecl hmiNETBIOSSendData               ( PSTR pHeader, W32 wHSize, 
  253.                                                PSTR pData,   W32 wDSize,
  254.                                                W32 wNode );
  255. BOOL    cdecl hmiNETBIOSGetData                ( PSTR pHeader,  W32 wHSize, 
  256.                                                PSTR pData,    W32 wDSize );
  257. BOOL    cdecl    hmiNETBIOSCancelAll              ( VOID );
  258. BOOL    cdecl hmiNETBIOSGetHeader              ( PSTR pHeader,   W32 wHSize, 
  259.                                                PSTR * pPacket );
  260. W32    cdecl hmiNETBIOSDeleteNode             ( W32 wNode );
  261.  
  262.